#include "../include/Socket.hpp"
#include <unistd.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <iostream>

namespace wd{

Socket::Socket(){
    //创建socket对象
    _fd = socket(AF_INET,SOCK_STREAM,0);
    if(_fd < 0){
        perror("socket");
    }

}

Socket::Socket(int fd)
:_fd(fd)
{}

Socket::~Socket(){
    close(_fd);
}

int Socket::fd() const{
    return _fd;
}

void Socket::shutdowdWrite(){
    //主动断开连接
    shutdown(_fd, SHUT_WR);
}

} //end of namepace wd
